/**
 * 首页 created to by doujiabao
 */

import React, { Component } from 'react'

import Page from 'components/Page'
import StandardGroupImgItem from 'components/StandardGroupImgItem'

class Index extends Component {

    constructor(props) {
        super(props)
        this.state = {
            data: {}
        }
        this.fetchData.bind(this)
    }

    componentDidMount() {
        this.fetchData()
    }

    fetchData = () => {
        fetch(
            '/api/app/v1/recommend/image?companyId=10126&eid=666666&pid=200',
            {
                body: JSON.stringify({ "pageIndex": 2, "pageSize": 10, "imageLevel": 0 }),
                cache: 'no-cache',
                credentials: 'include',
                headers: {
                    'Content-Type': 'application/json;charset=UTF-8',
                    'sign': '559702539f659733ca05341556457b18',
                    'Referer': 'http://92.levect.com/?utm_source=666666&eid=666666',
                    'Cookie': '_ga=GA1.2.282973850.1595743381; _gid=GA1.2.1293958347.1595743381; _gat_gtag_UA_168722770_1=1; hk-share=eyJsYW4iOiJ6aCIsInVzZXIiOnsiZGlkIjoiMTU5NTc0MzM3NjA1NDE4MDU3NDc2MzU3NzU0MDc2In0sInNpZ24iOiJmN2Y0NmVjZTNiNDBkIiwiX2V4cGlyZSI6MjQ2MDA4ODkwNTk5MiwiX21heEFnZSI6ODY0MDAwMDAwMDAwfQ==; hk-share.sig=C25EW6CrKzGmk8yLaQRpp1hj7tg'
                },
                method: 'POST',
                referrer: 'http://92.levect.com/?utm_source=666666&eid=666666'
            }
        ).then(function (response) {
            return response.json()
        }).then((res) => {
            this.setState({
                data: res.body
            })
        })
    }

    render() {

        const {
            data
        } = this.state

        const {
            result = []
        } = data

        return (<Page>

            <div className='home'>
                {result.map((data, idx) => (
                    <StandardGroupImgItem
                        key={idx}
                        data={data}
                    />
                ))}
            </div>

            <style>{`
                .home {
                    font-size: 16px;
                }
            `}</style>

        </Page>)
    }
}

export default Index